<?php
class Template
{
	private $data = array();
	
	private $layout;
	
	public function __construct()
	{
		
	}
	
	public function set($name, $value = NULL)
	{
		if ( ! is_array($name)) {
			$this->data[$name] = $value;
			return true;
		}
		foreach ($name as $k => $v) {
			$this->data[$k] = $v;
		}
	}
	

	public function view($file = NULL, $layout = NULL, $return = false)
	{
		$fw = Controller::get_instance();
		if ( ! $file) {
			$file = C::c . DS . C::m;
		}
		if ( ! file_exists(TEMPLATE_DIR . $file . EXT)) system_error();
		if ($this->layout) {
			$fw->load->view($layout . '_layout');
		}
		
		if ($return) 
		{
			return $fw->load->view($file, $this->data); 
		}
		else
		{
			echo $fw->load->view($file, $this->data);
		}
	}
	
	public function set_layout()
	{
		
	}
	
	public function add_css()
	{
		
	}
	
	public function add_js()
	{
		
	}
}